package com.cat.practice;

/**
 * @author cat
 * @description 单调队列模板
 * @create 2025/7/26 18:08
 * @since JDK17
 */

public class Solution03 {
    public static int N = ((int) (1e5 + 10)), h, t;
    public static int[] deque = new int[N];

    int[] f(int[] nums, int k) {    // 找最大的
        h = t = 0;
        int n = nums.length;
        int[] ans = new int[n - k + 1];
        for (int i = 0; i < k - 1; i++) {   // 先放入k - 1个数字
            while (h < t && nums[deque[t - 1]] <= nums[i]) { // 大 -> 小
                t--;
            }
            deque[t++] = i; // 把这下标放进去
        }

        for (int i = k - 1, l = 0; i < n; i++) {
            while (h < t && nums[deque[t - 1]] <= nums[i]) {
                t--;
            }

        }
        return ans;
    }

    public static void main(String[] args) {

    }
}
